import request from '@/config/axios'

/** 刷卡记录信息 */
export interface DeviceGateRecord {
  id: number // 编号
  cardNumber?: string // 卡号
  gateName?: string // 几号门
  schoolCode?: string // 所属园区
  classId?: number // 班级ID
  studentId?: number // 学生ID
  studentName?: string // 学生姓名
  sex?: number // 性别
  remark: string // 备注
  status?: number // 状态
}

// 刷卡记录 API
export const DeviceGateRecordApi = {
  // 查询刷卡记录分页
  getDeviceGateRecordPage: async (params: any) => {
    return await request.get({ url: `/school/device-gate-record/page`, params })
  },

  // 查询刷卡记录详情
  getDeviceGateRecord: async (id: number) => {
    return await request.get({ url: `/school/device-gate-record/get?id=` + id })
  },
  // 查询考勤报表
  getDeviceGateRecordReport: async (classId: number, queryDate: string) => {
    return await request.get({
      url: `/school/device-gate-record/report?classId=${classId}&queryDate=${queryDate}`
    })
  },

  // 新增刷卡记录 补卡
  createDeviceGateRecord: async (data: any) => {
    return await request.post({ url: `/school/device-gate-record/create`, data })
  },

  // 修改刷卡记录
  updateDeviceGateRecord: async (data: DeviceGateRecord) => {
    return await request.put({ url: `/school/device-gate-record/update`, data })
  },

  // 删除刷卡记录
  deleteDeviceGateRecord: async (id: number) => {
    return await request.delete({ url: `/school/device-gate-record/delete?id=` + id })
  },

  /** 批量删除刷卡记录 */
  deleteDeviceGateRecordList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/device-gate-record/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出刷卡记录 Excel
  exportDeviceGateRecord: async (params) => {
    return await request.download({ url: `/school/device-gate-record/export-excel`, params })
  }
}
